package com.shujia.day11;

/*
    StringBuffer中的成员方法：
        添加功能
            public StringBuffer append(String str)
            public StringBuffer insert(int offset,String str)
        删除功能
            public StringBuffer deleteCharAt(int index)
            public StringBuffer delete(int start,int end)
        替换功能
            public StringBuffer replace(int start,int end,String str)
        反转功能
            public StringBuffer reverse()

 */
public class StringBufferDemo2 {
    public static void main(String[] args) {
        StringBuffer sb = new StringBuffer();
        System.out.println("sb: " + sb);
        System.out.println("------------------------");
        //public StringBuffer append(String str) 在StringBuffer末尾处添加新的字符串
//        StringBuffer sb2 = sb.append(100);
//        System.out.println("sb: "+sb);
//        System.out.println("sb2: "+sb2);
//        System.out.println(sb==sb2);
        sb.append(100);
        sb.append(12.343);
        sb.append(true);
        System.out.println("sb: " + sb);
        System.out.println("------------------------");

        //public StringBuffer insert(int offset,String str) 在StringBuffer指定位置中添加字符串
        //10012.343true
        sb.insert(10,"java");
        System.out.println("sb: " + sb);
        System.out.println("------------------------");

        //public StringBuffer deleteCharAt(int index) 指定索引删除StringBuffer某一个字符
        //10012.343tjavarue
        sb.deleteCharAt(5);
        System.out.println("sb: " + sb);
        System.out.println("------------------------");

        //public StringBuffer delete(int start,int end) 指定开始和结束索引，删除StringBuffer一部分字符
        //10012343tjavarue
        sb.delete(9,13); //[start, end)
        System.out.println("sb: " + sb);
        System.out.println("------------------------");

        //public StringBuffer replace(int start,int end,String str) 使用字符串替换StringBuffer一部分字符
        //10012343true
        sb.replace(6,9,"李刚");
        System.out.println("sb: " + sb);
        System.out.println("------------------------");

        //public StringBuffer reverse()
        //100123李刚rue
        sb.reverse();
        System.out.println("sb: " + sb);
        System.out.println("------------------------");








    }
}
